//
//  ClassTypeTableViewController.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/18.
//

#import "ClassTypeTableViewController.h"
#import "TwoTabButView.h"
#import "ClassTypeTableViewCell.h"
#import "AddClassTypeViewController.h"
#import "SetPreferentialClassTypeController.h"

@interface ClassTypeTableViewController ()<UITableViewDelegate,UITableViewDataSource,TwoTabButViewDelegate>
@end

@implementation ClassTypeTableViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.navgationheadv.titlelabel.text = @"班型信息";
    
    TwoTabButView *tabbutview = [[TwoTabButView alloc]initWithFrame:CGRectMake(0, APPheight-SafeAreaBottomHeight-65, APPwidth, 65)];
    tabbutview.delegate = self;
    [tabbutview.lefttabbut setTitle:@"创建新班型" forState:UIControlStateNormal];
    [tabbutview.righttabbut setTitle:@"设置班型优惠" forState:UIControlStateNormal];
    [self.view addSubview:tabbutview];
    
}

- (void)setupUI {
    [super setupUI];
    self.tableView.frame = CGRectMake(0, SafeAreaTopHight, APPwidth, APPheight-SafeAreaTopHight-SafeAreaBottomHeight-65);
}


#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    return self.dataArray.count;
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 125;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ClassTypeTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"ClassTypeTableViewCell"];
    if (!cell) {
        cell=[[ClassTypeTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ClassTypeTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.editorBut addTarget:self action:@selector(editorButCheng:) forControlEvents:UIControlEventTouchUpInside];
    cell.editorBut.tag = indexPath.row;
    [cell.deleteBut addTarget:self action:@selector(deleteButCheng:) forControlEvents:UIControlEventTouchUpInside];
    cell.deleteBut.tag = indexPath.row;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 15;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc]init];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}

#pragma mark -编辑班型
-(void)editorButCheng:(UIButton *)but
{
    AddClassTypeViewController *vc = [[AddClassTypeViewController alloc]init];
    vc.VCType = 2;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark -删除班型
-(void)deleteButCheng:(UIButton *)but
{
    
}

#pragma mark -TwoTabButViewDelegate
-(void)TwoTabButViewBtnSelectedDelegate:(NSInteger)tag
{
    if (tag == 0) {
        NSLog(@"创建新班型");
        AddClassTypeViewController *vc = [[AddClassTypeViewController alloc]init];
        vc.VCType = 1;
        [self.navigationController pushViewController:vc animated:YES];
    }
    else{
        
        NSLog(@"设置优惠班型");
        SetPreferentialClassTypeController *vc = [[SetPreferentialClassTypeController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        
    }
}


-(void)returnback{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark -视图即将出现
-(void)viewWillAppear:(BOOL)animated{
        
    ((TabbarController *)self.tabBarController).tabBarView.hidden = YES;
    
}

@end
